package com.control;

import com.service.UserInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/*********************************
 * 文件名称: TestControl.inter
 * 功能说明:  
 * 开发人员：huangchenglong
 * 开发时间：2018/7/26 11:40
 *********************************/

@RestController
@RequestMapping()
public class TestControl {

    private static final Logger logger = LoggerFactory.getLogger(TestControl.class);

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Autowired
    private UserInfoService userInfoService;

    @RequestMapping("/test")
    public String test() {
        logger.info("进入test方法");
        return "SUCCESS";
    }

    @RequestMapping(value = "getUserInfo", method = RequestMethod.GET)
    public String getUserInfo(String id) {
        return userInfoService.get(id).toString();
    }

    @RequestMapping(value = "push")
    public String push() {
        rabbitTemplate.convertAndSend("order.exchange", "order","spring-msg");
        return "Push success";
    }
}